//
//  Team9BrowseTableViewCell.m
//  Team9Project
//
//  Created by 朱嘉祺 on 15/10/12.
//  Copyright © 2015年 apple. All rights reserved.
//

#import "Team9BrowseTableViewCell.h"
#import <Masonry.h>

#define WID 375.0
#define HEI 667.0

@implementation Team9BrowseTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}


-(void)createView{
//    self.contentView.backgroundColor = [UIColor colorWithWhite:0.667 alpha:0.5];
    self.view = [[UIView alloc] init];
//    self.view.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.view];
    self.imageviewBig = [[UIImageView alloc] init];
    [self.view addSubview:self.imageviewBig];
    
    self.imageview = [[UIImageView alloc] init];
    self.imageview.layer.cornerRadius = 20 / WID * WIDTH;
    self.imageview.layer.masksToBounds = YES;
    [self.view addSubview:self.imageview];
    
    self.imageviewSmall=[[UIImageView alloc] init];
    [self.view addSubview:self.imageviewSmall];
    
    self.labelPrice=[[UILabel alloc] init];
    self.labelPrice.layer.cornerRadius = 10 / WID * WIDTH;
    self.labelPrice.font = [UIFont systemFontOfSize:14 / WID * WIDTH];
    self.labelPrice.layer.masksToBounds = YES;
    self.labelPrice.textAlignment = NSTextAlignmentCenter;
    self.labelPrice.textColor = [UIColor whiteColor];
    self.labelPrice.backgroundColor = [UIColor orangeColor];
    [self.view addSubview:self.labelPrice];
    self.labelPrice.alpha = 0.6;
    
    self.labelname = [[Team9BaseLabel alloc] initWith:LableColorTypeOrangeGreen];
    self.labelname.font = [UIFont systemFontOfSize:14 / WID * WIDTH];
    self.labelname.alpha = 1;
//    self.labelname.textColor = [UIColor orangeColor];
    [self.view addSubview:self.labelname];
    
    self.labeldetail=[[Team9BaseLabel alloc] init];
    self.labeldetail.font=[UIFont systemFontOfSize:14 / WID * WIDTH];
    self.labeldetail.alpha = 1;
    [self.view addSubview:self.labeldetail];
    
    
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    [self.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(0 / WID * WIDTH);
        make.right.equalTo(self.contentView.mas_right).offset(0 / WID * WIDTH);
        make.top.equalTo(self.contentView.mas_top).offset(10 / WID * WIDTH);
        make.height.equalTo(@(270 / WID * WIDTH));
    }];

    [self.imageviewBig mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(10 / WID * WIDTH);
        make.right.equalTo(self.view.mas_right).offset(-10 / WID * WIDTH);
        make.top.equalTo(self.view.mas_top).offset(10 / WID * WIDTH);
        make.height.equalTo(@(200 / WID * WIDTH));
    }];

    [self.labelPrice mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.imageviewBig.mas_top).offset(10 / WID * WIDTH);
        make.right.equalTo(self.imageviewBig.mas_right).offset(-10 / WID * WIDTH);
        make.width.equalTo(@(110 / WID * WIDTH));
        make.height.equalTo(@(30 / WID * WIDTH));
    }];

    [self.imageview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.imageviewBig);
        make.top.equalTo(self.imageviewBig.mas_bottom).offset(10 / WID * WIDTH);
        make.width.height.equalTo(@(40 / WID * WIDTH));
    }];
    
    [self.labelname mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.imageview);
        make.left.equalTo(self.imageview.mas_right).offset(10 / WID * WIDTH);
        make.right.equalTo(self.imageviewBig);
        make.height.equalTo(@(30 / WID * WIDTH));
    }];
    
    [self.labeldetail mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.equalTo(self.labelname);
        make.bottom.equalTo(self.view.mas_bottom).offset(-3 / WID * WIDTH);
    }];
    
}



@end
